/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Test;

import MNetSockets.CmdChanel.CmdClient;
import MNetSockets.CmdChanel.IDataReader;
import MNetSockets.DataChanel.DataClient;
import MNetSockets.DataChanel.IUDPDataReader;
import Tool.CmdModel;
import Tool.FileCodeMaker;
import Tool.MovieList;
import Tool.ReportModel;
import java.io.File;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 *
 * @author wcss
 */
public class TestFrame extends javax.swing.JFrame implements IDataReader, IUDPDataReader, Runnable {

    public CmdClient cc = new CmdClient();
    public DataClient dc = new DataClient(63891);
    private File currentSelected = null;
    private long msgIndex = 0;
    public ArrayList<String> ipList = new ArrayList<String>();
    private Boolean isRunTest = false;
    private Thread udpTest = null;
    private int udpTestCount = 100;
    private int currentTestIndex = 0;

    public long getMsgIndex() {
        msgIndex++;
        return msgIndex;
    }

    public void sendUDPMsg(String ip, String content) {
        try {
            dc.send(new InetSocketAddress(ip, 63891), content + "-MsgIndex:" + getMsgIndex());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Creates new form TestFrame
     */
    public TestFrame() {
        initComponents();
        cc.dataReadEvent = this;
        dc.receiveEvent = this;
        try {
            dc.start();
        } catch (Exception ex) {
            Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnOpen = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtCode = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtType2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtReadme = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtPic = new javax.swing.JTextField();
        txtType1 = new javax.swing.JTextField();
        btnMovie = new javax.swing.JButton();
        btnMovieList = new javax.swing.JButton();
        btnRecreation = new javax.swing.JButton();
        btnAddMovie = new javax.swing.JButton();
        lblState = new javax.swing.JLabel();
        btnReport = new javax.swing.JButton();
        btnQueryMovie = new javax.swing.JButton();
        btnQueryNameMovie = new javax.swing.JButton();
        btnSelect = new javax.swing.JButton();
        btnGetMovieList = new javax.swing.JButton();
        btnSendToSelf = new javax.swing.JButton();
        btnUDPRemoteTest = new javax.swing.JButton();
        lblUDPTestCount = new javax.swing.JLabel();
        btnStopUDPTest = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnOpen.setText("Open");
        btnOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOpenActionPerformed(evt);
            }
        });
        getContentPane().add(btnOpen, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        btnClose.setText("Close");
        btnClose.setEnabled(false);
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });
        getContentPane().add(btnClose, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 10, -1, -1));

        jLabel2.setText("名称");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 90, 50, -1));

        txtName.setText("阿娘使道传");
        getContentPane().add(txtName, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 90, 573, -1));

        jLabel3.setText("代码");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 120, 50, -1));

        txtCode.setText("ignature_00244548471258141258");
        getContentPane().add(txtCode, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 120, 573, -1));

        jLabel4.setText("影片类型");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 150, -1, -1));

        jLabel5.setText("影片分类");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 190, -1, -1));

        txtType2.setText("2");
        getContentPane().add(txtType2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 190, 70, -1));

        jLabel6.setText("影片简介");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 210, -1, -1));

        txtReadme.setText("讲述了一名年轻郡守与含冤极影影院而死的女鬼相遇，在女鬼的帮助下侦破各种疑案，最终帮助女鬼报仇雪恨的故事。");
        getContentPane().add(txtReadme, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 210, 573, -1));

        jLabel7.setText("影片图片");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 240, -1, -1));

        txtPic.setText("http://pic.8090god.com/uploadimg/2012-8/20128168153847780.jpg");
        getContentPane().add(txtPic, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 240, 573, -1));

        txtType1.setText("1");
        getContentPane().add(txtType1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 150, 70, -1));

        btnMovie.setText("电影");
        btnMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMovieActionPerformed(evt);
            }
        });
        getContentPane().add(btnMovie, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 150, 70, -1));

        btnMovieList.setText("电视剧");
        btnMovieList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMovieListActionPerformed(evt);
            }
        });
        getContentPane().add(btnMovieList, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 150, 80, -1));

        btnRecreation.setText("娱乐节目");
        btnRecreation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRecreationActionPerformed(evt);
            }
        });
        getContentPane().add(btnRecreation, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 150, 90, -1));

        btnAddMovie.setText("添加影片");
        btnAddMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddMovieActionPerformed(evt);
            }
        });
        getContentPane().add(btnAddMovie, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 280, 150, -1));

        lblState.setText("状态");
        getContentPane().add(lblState, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 10, 830, 20));

        btnReport.setText("上报影片");
        btnReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReportActionPerformed(evt);
            }
        });
        getContentPane().add(btnReport, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 320, 150, -1));

        btnQueryMovie.setText("查询影片(代码)");
        btnQueryMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQueryMovieActionPerformed(evt);
            }
        });
        getContentPane().add(btnQueryMovie, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 360, 150, -1));

        btnQueryNameMovie.setText("查询影片（名称）");
        btnQueryNameMovie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQueryNameMovieActionPerformed(evt);
            }
        });
        getContentPane().add(btnQueryNameMovie, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 280, 170, -1));

        btnSelect.setText("选择");
        btnSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectActionPerformed(evt);
            }
        });
        getContentPane().add(btnSelect, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 90, 60, -1));

        btnGetMovieList.setText("获取影片列表");
        btnGetMovieList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGetMovieListActionPerformed(evt);
            }
        });
        getContentPane().add(btnGetMovieList, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 320, 170, -1));

        btnSendToSelf.setText("测试UDP通信(本地)");
        btnSendToSelf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSendToSelfActionPerformed(evt);
            }
        });
        getContentPane().add(btnSendToSelf, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 360, 170, -1));

        btnUDPRemoteTest.setText("测试UDP通信(远程)");
        btnUDPRemoteTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUDPRemoteTestActionPerformed(evt);
            }
        });
        getContentPane().add(btnUDPRemoteTest, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 280, 170, -1));
        getContentPane().add(lblUDPTestCount, new org.netbeans.lib.awtextra.AbsoluteConstraints(800, 80, 240, 140));

        btnStopUDPTest.setText("停止打洞测试");
        btnStopUDPTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStopUDPTestActionPerformed(evt);
            }
        });
        getContentPane().add(btnStopUDPTest, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 320, 170, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOpenActionPerformed
        // TODO add your handling code here:       

        try {
            cc.connect("58.64.177.195", 6502);
            this.btnOpen.setEnabled(false);
            this.btnClose.setEnabled(true);
        } catch (Exception ex) {
            Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnOpenActionPerformed

    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
        try {
            // TODO add your handling code here:
            cc.close();
            dc.stop();
            this.btnClose.setEnabled(false);
            this.btnOpen.setEnabled(true);
        } catch (Exception ex) {
            Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnCloseActionPerformed

    private void btnMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMovieActionPerformed
        // TODO add your handling code here:
        this.txtType1.setText("1");
    }//GEN-LAST:event_btnMovieActionPerformed

    private void btnMovieListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMovieListActionPerformed
        // TODO add your handling code here:
        this.txtType1.setText("2");
    }//GEN-LAST:event_btnMovieListActionPerformed

    private void btnRecreationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRecreationActionPerformed
        // TODO add your handling code here:
        this.txtType1.setText("3");
    }//GEN-LAST:event_btnRecreationActionPerformed

    private void btnAddMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddMovieActionPerformed
        // TODO add your handling code here:
        CmdModel ma = MovieList.addMovie(this.txtName.getText(), this.txtCode.getText(), this.txtType1.getText(), this.txtType2.getText(), this.txtReadme.getText(), this.txtPic.getText());
        cc.sendWithJson(ma);
    }//GEN-LAST:event_btnAddMovieActionPerformed

    private void btnReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReportActionPerformed
        // TODO add your handling code here:
        cc.sendWithJson(MovieList.reportMovie(new ReportModel[]{new ReportModel(this.txtCode.getText().trim(), "Tokyo Host")}));
    }//GEN-LAST:event_btnReportActionPerformed

    private void btnQueryMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQueryMovieActionPerformed
        // TODO add your handling code here:
        cc.sendWithJson(MovieList.queryMovieCodePeers(this.txtCode.getText().trim()));
    }//GEN-LAST:event_btnQueryMovieActionPerformed

    private void btnQueryNameMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQueryNameMovieActionPerformed
        // TODO add your handling code here:
        cc.sendWithJson(MovieList.queryMovieNamePeers("Tokyo Host"));
    }//GEN-LAST:event_btnQueryNameMovieActionPerformed

    private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        //是否可多选   
        fc.setMultiSelectionEnabled(false);
        //选择模式，可选择文件和文件夹   
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
//      fc.setFileSelectionMode(JFileChooser.FILES_ONLY);   
//      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);   
        //设置是否显示隐藏文件   
        fc.setFileHidingEnabled(true);
        fc.setAcceptAllFileFilterUsed(false);
        //设置文件筛选器   
//        fc.setFileFilter(new MyFilter("java"));  
//        fc.setFileFilter(new MyFilter("zip"));  

        int returnValue = fc.showOpenDialog(null);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            currentSelected = fc.getSelectedFile();
            this.txtName.setText(currentSelected.getName());
            this.txtReadme.setText(currentSelected.getName());
            try {
                this.txtCode.setText(FileCodeMaker.makeFileCode(currentSelected));
                //fc.getSelectedFiles()
            } catch (Exception ex) {
                Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btnSelectActionPerformed

    private void btnGetMovieListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetMovieListActionPerformed
        // TODO add your handling code here:
        cc.sendWithJson(MovieList.getMovieList());
    }//GEN-LAST:event_btnGetMovieListActionPerformed

    private void btnSendToSelfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendToSelfActionPerformed
        // TODO add your handling code here:
        sendUDPMsg("127.0.0.1", "本地消息测试！");
    }//GEN-LAST:event_btnSendToSelfActionPerformed

    private void btnUDPRemoteTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUDPRemoteTestActionPerformed
        // TODO add your handling code here:
        sendUDPMsg("108.171.204.250", "Areyouok?");
    }//GEN-LAST:event_btnUDPRemoteTestActionPerformed

    private void btnStopUDPTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopUDPTestActionPerformed
        // TODO add your handling code here:
        this.stopTest();
    }//GEN-LAST:event_btnStopUDPTestActionPerformed

    public void startTest() {
        currentTestIndex = 0;
        isRunTest = true;
//        udpTest = new Thread(this);
//        udpTest.setDaemon(true);
//        udpTest.start();
    }

    public void stopTest() {
        isRunTest = false;
        this.lblUDPTestCount.setText("打洞测试停止！");
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TestFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TestFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TestFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TestFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TestFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddMovie;
    private javax.swing.JButton btnClose;
    private javax.swing.JButton btnGetMovieList;
    private javax.swing.JButton btnMovie;
    private javax.swing.JButton btnMovieList;
    private javax.swing.JButton btnOpen;
    private javax.swing.JButton btnQueryMovie;
    private javax.swing.JButton btnQueryNameMovie;
    private javax.swing.JButton btnRecreation;
    private javax.swing.JButton btnReport;
    private javax.swing.JButton btnSelect;
    private javax.swing.JButton btnSendToSelf;
    private javax.swing.JButton btnStopUDPTest;
    private javax.swing.JButton btnUDPRemoteTest;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel lblState;
    private javax.swing.JLabel lblUDPTestCount;
    private javax.swing.JTextField txtCode;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtPic;
    private javax.swing.JTextField txtReadme;
    private javax.swing.JTextField txtType1;
    private javax.swing.JTextField txtType2;
    // End of variables declaration//GEN-END:variables

    @Override
    public void dataRead(Object o, Object o1) {
        String data = o1.toString().replaceAll("###", "").trim();
        System.out.println("Read:(" + data + ")");
        JSONObject jsons = JSONObject.fromObject(data);
        Boolean runresult = jsons.getJSONObject("return").getBoolean("res");
        if (jsons.getString("fun").equals("init")) {
            this.lblState.setText("初始化成功!");
        } else if (jsons.getString("fun").equals("addlist")) {
            if (runresult) {
                this.lblState.setText("影片添加成功！");
            } else {
                this.lblState.setText("影片添加失败！");
            }
        } else if (jsons.getString("fun").equals("report_movie")) {
            if (runresult) {
                this.lblState.setText("资源上报成功！");
            } else {
                this.lblState.setText("资源上报失败！");
            }
        } else if (jsons.getString("fun").equals("links")) {
            String ips = jsons.getJSONObject("return").getString("msg");
            ipList.clear();
            ipList.add(ips);

            sendUDPMsg("108.171.204.250", "saveserver");
            clientType = "server";
            remotePort = 0;
            this.startTest();

        } else if (jsons.getString("fun").equals("udp_down")) {

            JSONArray jarr = jsons.getJSONObject("return").getJSONArray("msg");
            ipList.clear();
            for (int k = 0; k < jarr.size(); k++) {
                String ipss = jarr.getString(k);
                ipList.add(ipss);
            }

            sendUDPMsg("108.171.204.250", "saveclient");
            clientType = "client";
            remotePort = 0;
            this.startTest();
            
            sendUDPMsg("108.171.204.250", "toclient");
        }
    }
    private Boolean udpTestOk = false;
    private int remotePort = 0;
    private String remoteAddress = "";
    private String clientType = "";

    @Override
    public void dataRead(Object o, SocketAddress sa, Object o1) {
        String curIP = ((InetSocketAddress) sa).getAddress().getHostAddress();
        System.out.println("消息到达 IP:" + curIP + " 内容：" + o1.toString());
        this.lblState.setText("消息到达：" + curIP + " " + o1.toString());
        String cmd = o1.toString().replace("{@@}", "").replace("{##}", "");

        if (o1.toString().contains("toclient:")) 
        {
            remoteAddress = cmd.replace("toclient:", "").split("><")[0];
            remotePort = Integer.parseInt(cmd.replace("toclient:", "").split("><")[1]);
            try {
                dc.send(new InetSocketAddress(remoteAddress,remotePort), "x1x2");
            } catch (Exception ex) {
                Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            sendUDPMsg("108.171.204.250", "toserver");
        }
        
        if (o1.toString().contains("toserver:")) 
        {
            remoteAddress = cmd.replace("toserver:", "").split("><")[0];
            remotePort = Integer.parseInt(cmd.replace("toserver:", "").split("><")[1]);
            try {
                dc.send(new InetSocketAddress(remoteAddress,remotePort), "x3x4");
            } catch (Exception ex) {
                Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            sendUDPMsg("108.171.204.250", "toclient");
        }

        if (o1.toString().contains("x1x2"))
        {
            this.stopTest();
            this.lblUDPTestCount.setText("打洞成功！");
        }
        
        if (o1.toString().contains("x3x4"))
        {
            this.stopTest();
            this.lblUDPTestCount.setText("打洞成功！");
        }
    }

    @Override
    public void run() {
        while (isRunTest) {
            currentTestIndex++;
            this.lblUDPTestCount.setText("正在进行第" + currentTestIndex + "次打滑尝试!");

            if (clientType.equals("server")) {
                sendUDPMsg("108.171.204.250", "toserver");
            } else {
                sendUDPMsg("108.171.204.250", "toclient");
            }

            try {
                Thread.sleep(600);
            } catch (InterruptedException ex) {
                Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}